package com.formation.userbase.webapp.actions;

import java.util.List;

import com.formation.userbase.persistance.beans.Product;
import com.formation.userbase.persistance.services.ProductService;
import com.opensymphony.xwork2.ActionSupport;

public class ProductAction extends ActionSupport {


	Product p;
	List<Product> lProduct;
	ProductService pserv;
	
	


	public Product getP() {
		return p;
	}


	public void setP(Product p) {
		this.p = p;
	}


	public List<Product> getLProduct() {
		return lProduct;
	}


	public void setLProduct(List<Product> product) {
		lProduct = product;
	}


	public ProductService getPserv() {
		return pserv;
	}


	public void setPserv(ProductService pserv) {
		this.pserv = pserv;
	}


	
	
	public String ProductAfficheList(){
		lProduct= pserv.getAllProduct();
		
		return SUCCESS;
	}
	
	
	public String AfficheForminscription(){
		
		return SUCCESS;
	}
	
	public String ProductverifInscription(){
		if(pserv.insert(getP())){
			addActionMessage("inscription realise avec succes, vous pouvez desormais vous logguer");
			return "success";
		}
		else{
			addActionError("erreur inscription verifiez vos champs");
			return "error";
		}
	}
	
	
}
